package main

import (
	"fmt"
	"reflect"
)

//通过反射修改值
func main() {
	num1 := 10
	//changeVal(num1) //panic: reflect: call of reflect.Value.Elem on int Value
	changeVal(&num1) //必须传入指针
	fmt.Println(num1)
}

func changeVal(val interface{}) {
	rVal := reflect.ValueOf(val)
	rVal.Elem().SetInt(100)
}
